package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.enumclass.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Created by HK on 16/10/10.
 */
@Table(name = "merchant_order")
@Entity
@DynamicUpdate
@DynamicInsert
public class MerchantOrder extends IDEntityMall {

    @Column(columnDefinition = "varchar(100) comment '订单号'")
    private String orderNum;
    @Column(columnDefinition = "bigint comment '平台 订单id'")
    private Long mallOrderId;
    @Column(columnDefinition = "varchar(100) comment '平台订单号'")
    private String mallOrderNum;
    @Column(columnDefinition = "bigint comment '平台id'")
    private Long mallId;
    @Column(columnDefinition = "bigint comment '客户id'")
    private Long customerId;
    @Column(columnDefinition = "varchar(30) comment '客户名称'")
    private String customerName;
    @Column(columnDefinition = "bigint comment '商户id'")
    private Long merchantId;
    @Column(columnDefinition = "varchar(30) comment '商户名称'")
    private String merchantName;
    @Column(columnDefinition = "bigint comment '商户门店 id'")
    private Long merchantStoreId;
    @Column(columnDefinition = "DECIMAL(30,10) comment '总金额'")
    private BigDecimal totalAmount;
    @Column(columnDefinition = "DECIMAL(30,10) comment '优惠后金额'")
    private BigDecimal discountAmount;
    @Column(columnDefinition = "DECIMAL(30,10) comment '卡券优惠金额'")
    private BigDecimal couponDiscountAmount;
    @Column(columnDefinition = "varchar(100) comment '收货人地址'", name = "address")
    private String shoppingAddress;
    @Column(columnDefinition = "varchar(100) comment '收货人'")
    private String shoppingMan;
    @Column(columnDefinition = "varchar(100) comment '收货人电话号码'")
    private String shoppingManPhone;
    @Column(columnDefinition = "varchar(30) comment '订单状态 WAIT_PAYING(\"待支付\"),CANCEL(\"取消\"),PAYED(\"已支付\"),WAIT_SHIPPED(\"等待发货\"),SHIPPED(\"已发货\"),SHOP_PICKUP(\"到店自提\"),WAIT_STOCK(\"待备货\"),WAIT_SHOP_PICKUP(\"待到店自提\"),CONFIRM(\"已确认\"),WAIT_USE(\"待使用\"),PART_USE(\"部分使用\"),USED(\"已使用\"),FINISHED(\"已完成\"),APPLY_REJECT(\"申请退货\"),FINISHED_REJECT(\"已完成退货\"),APPLY_REFUND(\"申请退款\"),FINISHED_REFUND(\"已完成退款\")'")
    @Enumerated(EnumType.STRING)
    private OrderStatus status;
    @Column(columnDefinition = "varchar(255) comment'评价状态'")
    @Enumerated(EnumType.STRING)
    private EvaluateStatus evaluateStatus = EvaluateStatus.DEFAULT;
    @Column(columnDefinition = "varchar(70) comment '物流单号'")
    private String logisticsNumber;
    @Column(columnDefinition = "bigint comment '物流公司ID(其它为0)'")
    private Long logisticsId;
    @Column(columnDefinition = "varchar(30) comment '物流公司编码'")
    private String logisticsCode;
    @Column(columnDefinition = "varchar(70) comment '物流公司名称'")
    private String logisticsName;
    @Column(columnDefinition = "datetime comment '发货时间'")
    private Date dateDelivered;
    @Column(columnDefinition = "datetime comment '收货时间'")
    private Date dateReceived;
    @Column(columnDefinition = "varchar(255) comment '备注'")
    private String remark;
    @Column(columnDefinition = "varchar(30) comment '物流种类 SHOP_PICKUP(\"到店自提\"), SHIPPING(\"物流\")'")
    @Enumerated(EnumType.STRING)
    private ProductShippingType productShoppingType;
    @Column(columnDefinition = "varchar(30) comment '订单类型 GOODS(\"实物商品\"), SERVICE(\"到店服务\")'")
    @Enumerated(EnumType.STRING)
    private OrderType orderType;
    @Column(columnDefinition = "varchar(30) comment '是否支持过期退 当订单类型为服务,此字段才生效 YES(\"是\"), NO(\"否\")'")
    @Enumerated(EnumType.STRING)
    private Whether refundable;
    @Column(columnDefinition = "varchar(30) comment '结算状态 WAIT_SETTLE(\"待结算\"), PART_SETTLE(\"部分结算\"), SETTLED(\"已结算\")'")
    @Enumerated(EnumType.STRING)
    private SettlementStatus settleStatus = SettlementStatus.WAIT_SETTLE;
    @Column(columnDefinition = "varchar(50) comment '渠道分销码'")
    private String channelSalesCode;
    @Column(columnDefinition = "varchar(30) comment '支付方式 WECHAT(\"微信\")'")
    @Enumerated(EnumType.STRING)
    private PaymentMethod paymentMethod;
    @Column(columnDefinition = "datetime comment '支付时间'")
    private Date datePayment;
    @Column(columnDefinition = "datetime comment '备货时间'")
    private Date dateStock;
    @Column(columnDefinition = "varchar(30) comment '商家角色。当订单为分销订单时,用于区分供应商或者分销商 SELF(\"默认\"),SUPPLIER(\"供应商\"), DISTRIBUTOR(\"分销商\")'")
    @Enumerated(EnumType.STRING)
    private MerchantOrderMerchantRole merchantRole = MerchantOrderMerchantRole.SELF;
    @Column(columnDefinition = "varchar(30) comment 'SELF(\"自营下单\"), MARKET(\"分销下单\")'")
    @Enumerated(EnumType.STRING)
    private MerchantOrderSourceType sourceType;
    @Column(columnDefinition = "varchar(100) comment '分销订单号'")
    private String marketOrderNum;
    @Column(columnDefinition = "bigint comment '礼包id 当礼包下单时，该字段不能为空'")
    private Long giftPacketId;
    @Column(columnDefinition = "varchar(30) comment '客户手动退款状态 REFUNDED(\"已退款\"), NOTREFUND(\"未退款\")'")
    @Enumerated(EnumType.STRING)
    private RefundType refundType = RefundType.NOTREFUND;
    @Column(columnDefinition = "bigint comment '商家资金账户ID'")
    private Long merchantFundId;
    /**
     * 订单来源，WXAPP:微信小程序；WEXIN:公众号H5
     */
    @Column(columnDefinition = "varchar(100) comment '订单来源，WXAPP:微信小程序；WECHAT:公众号H5'")
    @Enumerated(EnumType.STRING)
    private OrderSource orderSource;
    public final static String CHECK_LOGISTICS_ID_IS_NOT_NULL = "物流公司ID 不能为空";
    public final static String CHECK_LOGISTICS_NUMBER_IS_NOT_NULL = "物流订单号 不能为空";
    public final static String MERCHANT_ORDER_WAIT_SHIPPED = "订单不处于发货状态 不能做此操作";

    public Long getMallOrderId() {
        return mallOrderId;
    }

    public void setMallOrderId(Long mallOrderId) {
        this.mallOrderId = mallOrderId;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public String getMallOrderNum() {
        return mallOrderNum;
    }

    public void setMallOrderNum(String mallOrderNum) {
        this.mallOrderNum = mallOrderNum;
    }

    public String getShoppingAddress() {
        return shoppingAddress;
    }

    public void setShoppingAddress(String shoppingAddress) {
        this.shoppingAddress = shoppingAddress;
    }

    public String getShoppingMan() {
        return shoppingMan;
    }

    public void setShoppingMan(String shoppingMan) {
        this.shoppingMan = shoppingMan;
    }

    public String getShoppingManPhone() {
        return shoppingManPhone;
    }

    public void setShoppingManPhone(String shoppingManPhone) {
        this.shoppingManPhone = shoppingManPhone;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    public String getLogisticsNumber() {
        return logisticsNumber;
    }

    public void setLogisticsNumber(String logisticsNumber) {
        this.logisticsNumber = logisticsNumber;
    }

    public Long getLogisticsId() {
        return logisticsId;
    }

    public void setLogisticsId(Long logisticsId) {
        this.logisticsId = logisticsId;
    }

    public String getLogisticsName() {
        return logisticsName;
    }

    public void setLogisticsName(String logisticsName) {
        this.logisticsName = logisticsName;
    }

    public Date getDateDelivered() {
        return dateDelivered;
    }

    public void setDateDelivered(Date dateDelivered) {
        this.dateDelivered = dateDelivered;
    }

    public Date getDateReceived() {
        return dateReceived;
    }

    public void setDateReceived(Date dateReceived) {
        this.dateReceived = dateReceived;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public ProductShippingType getProductShoppingType() {
        return productShoppingType;
    }

    public void setProductShoppingType(ProductShippingType productShoppingType) {
        this.productShoppingType = productShoppingType;
    }

    public OrderType getOrderType() {
        return orderType;
    }

    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    public SettlementStatus getSettleStatus() {
        return settleStatus;
    }

    public void setSettleStatus(SettlementStatus settleStatus) {
        this.settleStatus = settleStatus;
    }

    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public Date getDatePayment() {
        return datePayment;
    }

    public void setDatePayment(Date datePayment) {
        this.datePayment = datePayment;
    }

    public MerchantOrderSourceType getSourceType() {
        return sourceType;
    }

    public void setSourceType(MerchantOrderSourceType sourceType) {
        this.sourceType = sourceType;
    }

    public Long getMerchantStoreId() {
        return merchantStoreId;
    }

    public void setMerchantStoreId(Long merchantStoreId) {
        this.merchantStoreId = merchantStoreId;
    }

    public String getChannelSalesCode() {
        return channelSalesCode;
    }

    public void setChannelSalesCode(String channelSalesCode) {
        this.channelSalesCode = channelSalesCode;
    }

    public String getMarketOrderNum() {
        return marketOrderNum;
    }

    public void setMarketOrderNum(String marketOrderNum) {
        this.marketOrderNum = marketOrderNum;
    }

    public MerchantOrderMerchantRole getMerchantRole() {
        return merchantRole;
    }

    public void setMerchantRole(MerchantOrderMerchantRole merchantRole) {
        this.merchantRole = merchantRole;
    }

    public EvaluateStatus getEvaluateStatus() {
        return evaluateStatus;
    }

    public void setEvaluateStatus(EvaluateStatus evaluateStatus) {
        this.evaluateStatus = evaluateStatus;
    }

    public String getLogisticsCode() {
        return logisticsCode;
    }

    public void setLogisticsCode(String logisticsCode) {
        this.logisticsCode = logisticsCode;
    }

    public BigDecimal getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(BigDecimal discountAmount) {
        this.discountAmount = discountAmount;
    }

    public BigDecimal getCouponDiscountAmount() {
        return couponDiscountAmount;
    }

    public void setCouponDiscountAmount(BigDecimal couponDiscountAmount) {
        this.couponDiscountAmount = couponDiscountAmount;
    }

    public Whether getRefundable() {
        return refundable;
    }

    public void setRefundable(Whether refundable) {
        this.refundable = refundable;
    }

    public Date getDateStock() {
        return dateStock;
    }

    public void setDateStock(Date dateStock) {
        this.dateStock = dateStock;
    }

    public Long getGiftPacketId() {
        return giftPacketId;
    }

    public void setGiftPacketId(Long giftPacketId) {
        this.giftPacketId = giftPacketId;
    }

    public RefundType getRefundType() {
        return refundType;
    }

    public void setRefundType(RefundType refundType) {
        this.refundType = refundType;
    }

    public Long getMerchantFundId() {
        return merchantFundId;
    }

    public void setMerchantFundId(Long merchantFundId) {
        this.merchantFundId = merchantFundId;
    }

    public OrderSource getOrderSource() {
        return orderSource;
    }

    public void setOrderSource(OrderSource orderSource) {
        this.orderSource = orderSource;
    }

    @Override
    public String toString() {
        return "MerchantOrder{" +
                "orderNum='" + orderNum + '\'' +
                ", mallOrderId=" + mallOrderId +
                ", mallOrderNum='" + mallOrderNum + '\'' +
                ", mallId=" + mallId +
                ", customerId=" + customerId +
                ", customerName='" + customerName + '\'' +
                ", merchantId=" + merchantId +
                ", merchantName='" + merchantName + '\'' +
                ", merchantStoreId=" + merchantStoreId +
                ", totalAmount=" + totalAmount +
                ", discountAmount=" + discountAmount +
                ", couponDiscountAmount=" + couponDiscountAmount +
                ", shoppingAddress='" + shoppingAddress + '\'' +
                ", shoppingMan='" + shoppingMan + '\'' +
                ", shoppingManPhone='" + shoppingManPhone + '\'' +
                ", status=" + status +
                ", evaluateStatus=" + evaluateStatus +
                ", logisticsNumber='" + logisticsNumber + '\'' +
                ", logisticsId=" + logisticsId +
                ", logisticsCode='" + logisticsCode + '\'' +
                ", logisticsName='" + logisticsName + '\'' +
                ", dateDelivered=" + dateDelivered +
                ", dateReceived=" + dateReceived +
                ", remark='" + remark + '\'' +
                ", productShoppingType=" + productShoppingType +
                ", orderType=" + orderType +
                ", refundable=" + refundable +
                ", settleStatus=" + settleStatus +
                ", channelSalesCode='" + channelSalesCode + '\'' +
                ", paymentMethod=" + paymentMethod +
                ", datePayment=" + datePayment +
                ", dateStock=" + dateStock +
                ", merchantRole=" + merchantRole +
                ", sourceType=" + sourceType +
                ", marketOrderNum='" + marketOrderNum + '\'' +
                ", giftPacketId=" + giftPacketId +
                ", refundType=" + refundType +
                ", merchantFundId=" + merchantFundId +
                ", orderSource=" + orderSource +
                '}';
    }
}

